mainApp.directive("goodsListIndex", ['$q','goodsService', function ($q,goodsService) {
    return {
        restrict: 'E',
        scope: {},
        replace: true,
        templateUrl: function () {
            return "partial/goods_list.html";
        },
        link: function ($scope) {
        	$scope.baseUrl=baseUrl;
        	$scope.$on("leftListClick", function (evt, param) {
	                    console.info("收到广播");
                	});
    		var success=function(data){
			//console.info(data);
				if($scope.pageIndex==1){
					$scope.goodsList=data.data.list;
				}else{
					angular.forEach(data.data.list, function(goods) {
						$scope.goodsList.push(goods);
					});
				}
				
				console.info(data.data.list);
				console.info($scope.goodsList);
			}
			var error=function(err){
				console.info(err);
			}
				
    		$scope.pageIndex=1;
			$scope.pageSie=20;
			$scope.param={"checkStatus":'1'};//请求已上架商品
			var getList=function(pageIndex,pageSize,param){
				console.info(pageIndex);
				//请求商品列表数据
				goodsService.getGoogsList(pageIndex,pageSize,param,success,error) ;
			};
			//初始化列表数据
			getList($scope.pageIndex,$scope.pageSie,$scope.param);
			
			$scope.goodsDetailPage=function(goodsId){
					mui.openWindow({
						url:"goodsDetails.html",
						id:'goodsDetails.html',
					    extras:{
					        goodsId:goodsId
					    },
					    styles: {
							popGesture:"close"	
						}
					});
				}
        }
    }
}]);
mainApp.directive('onFinishRenderFilters', function ($timeout) {
    return {
        restrict: 'A',
        link: function(scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function() {
                    scope.$emit('ngRepeatFinished');
                });
            }
        }
    };
});